home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / var / lib / python-support / python2.6 / gdata / apps / emailsettings / service.pyc (.txt) < prev   
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  8.4 KB  |  245 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. """Allow Google Apps domain administrators to set users' email settings.
  5.  
  6.   EmailSettingsService: Set various email settings.
  7. """
  8. __author__ = 'google-apps-apis@googlegroups.com'
  9. import gdata.apps as gdata
  10. import gdata.apps.service as gdata
  11. import gdata.service as gdata
  12. API_VER = '2.0'
  13. KEEP = 'KEEP'
  14. ARCHIVE = 'ARCHIVE'
  15. DELETE = 'DELETE'
  16. ALL_MAIL = 'ALL_MAIL'
  17. MAIL_FROM_NOW_ON = 'MAIL_FROM_NOW_ON'
  18.  
  19. class EmailSettingsService(gdata.apps.service.PropertyService):
  20.     '''Client for the Google Apps Email Settings service.'''
  21.     
  22.     def _serviceUrl(self, setting_id, username, domain = None):
  23.         if domain is None:
  24.             domain = self.domain
  25.         
  26.         return '/a/feeds/emailsettings/%s/%s/%s/%s' % (API_VER, domain, username, setting_id)
  27.  
  28.     
  29.     def _bool2str(self, b):
  30.         if b is None:
  31.             return None
  32.         return str(b is True).lower()
  33.  
  34.     
  35.     def CreateLabel(self, username, label):
  36.         '''Create a label.
  37.  
  38.     Args:
  39.       username: User to create label for.
  40.       label: Label to create.
  41.  
  42.     Returns:
  43.       A dict containing the result of the create operation.
  44.     '''
  45.         uri = self._serviceUrl('label', username)
  46.         properties = {
  47.             'label': label }
  48.         return self._PostProperties(uri, properties)
  49.  
  50.     
  51.     def CreateFilter(self, username, from_ = None, to = None, subject = None, has_the_word = None, does_not_have_the_word = None, has_attachment = None, label = None, should_mark_as_read = None, should_archive = None):
  52.         '''Create a filter.
  53.  
  54.     Args:
  55.       username: User to create filter for.
  56.       from_: Filter from string.
  57.       to: Filter to string.
  58.       subject: Filter subject.
  59.       has_the_word: Words to filter in.
  60.       does_not_have_the_word: Words to filter out.
  61.       has_attachment:  Boolean for message having attachment.
  62.       label: Label to apply.
  63.       should_mark_as_read: Boolean for marking message as read.
  64.       should_archive: Boolean for archiving message.
  65.  
  66.     Returns:
  67.       A dict containing the result of the create operation.
  68.     '''
  69.         uri = self._serviceUrl('filter', username)
  70.         properties = { }
  71.         properties['from'] = from_
  72.         properties['to'] = to
  73.         properties['subject'] = subject
  74.         properties['hasTheWord'] = has_the_word
  75.         properties['doesNotHaveTheWord'] = does_not_have_the_word
  76.         properties['hasAttachment'] = self._bool2str(has_attachment)
  77.         properties['label'] = label
  78.         properties['shouldMarkAsRead'] = self._bool2str(should_mark_as_read)
  79.         properties['shouldArchive'] = self._bool2str(should_archive)
  80.         return self._PostProperties(uri, properties)
  81.  
  82.     
  83.     def CreateSendAsAlias(self, username, name, address, reply_to = None, make_default = None):
  84.         '''Create alias to send mail as.
  85.  
  86.     Args:
  87.       username: User to create alias for.
  88.       name: Name of alias.
  89.       address: Email address to send from.
  90.       reply_to: Email address to reply to.
  91.       make_default: Boolean for whether this is the new default sending alias.
  92.  
  93.     Returns:
  94.       A dict containing the result of the create operation.
  95.     '''
  96.         uri = self._serviceUrl('sendas', username)
  97.         properties = { }
  98.         properties['name'] = name
  99.         properties['address'] = address
  100.         properties['replyTo'] = reply_to
  101.         properties['makeDefault'] = self._bool2str(make_default)
  102.         return self._PostProperties(uri, properties)
  103.  
  104.     
  105.     def UpdateForwarding(self, username, enable, forward_to = None, action = None):
  106.         '''Update forwarding settings.
  107.  
  108.     Args:
  109.       username: User to update forwarding for.
  110.       enable: Boolean whether to enable this forwarding rule.
  111.       forward_to: Email address to forward to.
  112.       action: Action to take after forwarding.
  113.  
  114.     Returns:
  115.       A dict containing the result of the update operation.
  116.     '''
  117.         uri = self._serviceUrl('forwarding', username)
  118.         properties = { }
  119.         properties['enable'] = self._bool2str(enable)
  120.         if enable is True:
  121.             properties['forwardTo'] = forward_to
  122.             properties['action'] = action
  123.         
  124.         return self._PutProperties(uri, properties)
  125.  
  126.     
  127.     def UpdatePop(self, username, enable, enable_for = None, action = None):
  128.         '''Update POP3 settings.
  129.  
  130.     Args:
  131.       username: User to update POP3 settings for.
  132.       enable: Boolean whether to enable POP3.
  133.       enable_for: Which messages to make available via POP3.
  134.       action: Action to take after user retrieves email via POP3.
  135.  
  136.     Returns:
  137.       A dict containing the result of the update operation.
  138.     '''
  139.         uri = self._serviceUrl('pop', username)
  140.         properties = { }
  141.         properties['enable'] = self._bool2str(enable)
  142.         if enable is True:
  143.             properties['enableFor'] = enable_for
  144.             properties['action'] = action
  145.         
  146.         return self._PutProperties(uri, properties)
  147.  
  148.     
  149.     def UpdateImap(self, username, enable):
  150.         '''Update IMAP settings.
  151.  
  152.     Args:
  153.       username: User to update IMAP settings for.
  154.       enable: Boolean whether to enable IMAP.
  155.  
  156.     Returns:
  157.       A dict containing the result of the update operation.
  158.     '''
  159.         uri = self._serviceUrl('imap', username)
  160.         properties = {
  161.             'enable': self._bool2str(enable) }
  162.         return self._PutProperties(uri, properties)
  163.  
  164.     
  165.     def UpdateVacation(self, username, enable, subject = None, message = None, contacts_only = None):
  166.         '''Update vacation settings.
  167.  
  168.     Args:
  169.       username: User to update vacation settings for.
  170.       enable: Boolean whether to enable vacation responses.
  171.       subject: Vacation message subject.
  172.       message: Vacation message body.
  173.       contacts_only: Boolean whether to send message only to contacts.
  174.  
  175.     Returns:
  176.       A dict containing the result of the update operation.
  177.     '''
  178.         uri = self._serviceUrl('vacation', username)
  179.         properties = { }
  180.         properties['enable'] = self._bool2str(enable)
  181.         if enable is True:
  182.             properties['subject'] = subject
  183.             properties['message'] = message
  184.             properties['contactsOnly'] = self._bool2str(contacts_only)
  185.         
  186.         return self._PutProperties(uri, properties)
  187.  
  188.     
  189.     def UpdateSignature(self, username, signature):
  190.         '''Update signature.
  191.  
  192.     Args:
  193.       username: User to update signature for.
  194.       signature: Signature string.
  195.  
  196.     Returns:
  197.       A dict containing the result of the update operation.
  198.     '''
  199.         uri = self._serviceUrl('signature', username)
  200.         properties = {
  201.             'signature': signature }
  202.         return self._PutProperties(uri, properties)
  203.  
  204.     
  205.     def UpdateLanguage(self, username, language):
  206.         '''Update user interface language.
  207.  
  208.     Args:
  209.       username: User to update language for.
  210.       language: Language code.
  211.  
  212.     Returns:
  213.       A dict containing the result of the update operation.
  214.     '''
  215.         uri = self._serviceUrl('language', username)
  216.         properties = {
  217.             'language': language }
  218.         return self._PutProperties(uri, properties)
  219.  
  220.     
  221.     def UpdateGeneral(self, username, page_size = None, shortcuts = None, arrows = None, snippets = None, unicode = None):
  222.         '''Update general settings.
  223.  
  224.     Args:
  225.       username: User to update general settings for.
  226.       page_size: Number of messages to show.
  227.       shortcuts: Boolean whether shortcuts are enabled.
  228.       arrows: Boolean whether arrows are enabled.
  229.       snippets: Boolean whether snippets are enabled.
  230.       unicode: Wheter unicode is enabled.
  231.  
  232.     Returns:
  233.       A dict containing the result of the update operation.
  234.     '''
  235.         uri = self._serviceUrl('general', username)
  236.         properties = { }
  237.         properties['pageSize'] = str(page_size)
  238.         properties['shortcuts'] = self._bool2str(shortcuts)
  239.         properties['arrows'] = self._bool2str(arrows)
  240.         properties['snippets'] = self._bool2str(snippets)
  241.         properties['unicode'] = self._bool2str(unicode)
  242.         return self._PutProperties(uri, properties)
  243.  
  244.  
  245.